package org.jctc.els.modules.biz.service.districts.impl;

import org.jctc.els.modules.biz.entity.districts.Districts;
import org.jctc.els.modules.biz.mapper.districts.DistrictsMapper;
import org.jctc.els.modules.biz.service.districts.IDistrictsService;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author: Ice
 * @Date: 2021/12/15
 */
@Service
public class DistrictsServiceImpl extends BaseServiceImpl<DistrictsMapper, Districts> implements IDistrictsService {

	@Autowired
	private DistrictsMapper districtsMapper;

	@Override
	public List<Districts> selectProvince() {
		List<Districts> districtsPages = districtsMapper.selectProvince();
		return districtsPages;
	}

	@Override
	public List<Districts> selectCity(String adCode) {
		List<Districts> districtsPages = districtsMapper.selectCity(adCode);
		return districtsPages;
	}

	@Override
	public List<Districts> selectDistrict(String cityCode) {
		List<Districts> districtsPages = districtsMapper.selectDistrict(cityCode);
		return districtsPages;
	}

	@Override
	public List<Districts> selectDistricts(String adCode) {
		List<Districts> districtsPages = districtsMapper.selectDistricts(adCode);
		return districtsPages;
	}

	@Override
	public boolean importData(Districts districts) {
		//TODO：创建Wrapper的N种方式
		//先删除已经存在数据
		districtsMapper.deletePhysical(districts.getAdCode());
		//再增加数据
		boolean result = districtsMapper.insert(districts) > 0;
		return result;
	}
}
